package org.monster.app;

/**
 * 应用上下文
 *
 * @author Monster
 */
public class AppContext {

    /**
     * 执行
     *
     * @param dosCommand   dos命令
     * @param dosParameter 命令参数
     */
    public void execute(String dosCommand, String dosParameter) {
        App app = AppObjectMap.get(dosCommand);
        app.execute(dosParameter);
    }

    /**
     * 替换
     *
     * @param dosCommand dos命令
     * @return dos命令
     */
    public String replace(String dosCommand) {
        ClassPath classPath = new ClassPath();
        String[] str = classPath.getClassPath(dosCommand);
        App webApp = AppObjectMap.get(str[1]);
        if (webApp == null) {
            webApp = AppFactory.getInstance(str[1]);
        }
        AppObjectMap objectMap = new AppObjectMap();
        objectMap.put(str[0], webApp);
        return webApp.replace(dosCommand);
    }
}
